home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / ip / ka9q / osrc.arc / NR4.H < prev    next >
Encoding:
C/C++ Source or Header  |  1989-02-17  |  4.7 KB  |  156 lines

  1. #ifndef    NR4MAXCIRC
  2.  
  3. #include "mbuf.h"
  4. #include "timer.h"
  5. #include "ax25.h"
  6.  
  7. /* nr4.h:  defines for netrom layer 4 (transport) support */
  8.  
  9. /* compile-time limitations */
  10.  
  11. #define    NR4MAXCIRC    20        /* maximum number of open circuits */
  12.  
  13. /* protocol limitation: */
  14.  
  15. #define    NR4MAXINFO    236        /* maximum data in an info packet */
  16.  
  17. /* flags in high nybble of opcode byte */
  18.  
  19. #define    NR4CHOKE    0x80
  20. #define    NR4NAK        0x40
  21. #define    NR4MORE        0x20    /* The "more follows" flag for */
  22.                             /* pointless packet reassembly */
  23.  
  24. /* mask for opcode nybble */
  25.  
  26. #define    NR4OPCODE    0x0f
  27.  
  28. /* opcodes */
  29.  
  30. #define NR4OPPID    0        /* protocol ID extension to network layer */
  31. #define    NR4OPCONRQ    1        /* connect request */
  32. #define    NR4OPCONAK    2        /* connect acknowledge */
  33. #define    NR4OPDISRQ    3        /* disconnect request */
  34. #define    NR4OPDISAK    4        /* disconnect acknowledge */
  35. #define    NR4OPINFO    5        /* information packet */
  36. #define    NR4OPACK    6        /* information ACK */
  37. #define NR4NUMOPS    7        /* number of transport opcodes */
  38.  
  39. /* minimum length of NET/ROM transport header */
  40.  
  41. #define    NR4MINHDR    5
  42.  
  43. /* host format net/rom transport header */
  44.  
  45. struct nr4hdr {
  46.     unsigned char opcode ;        /* opcode and flags */
  47.  
  48.     union {
  49.  
  50.         struct {                /* network extension */
  51.             unsigned char family ;    /* protocol family */
  52.             unsigned char proto ;    /* protocol within family */
  53.         } pid ;
  54.  
  55.         struct {                /* connect request */
  56.             unsigned char myindex ;    /* sender's circuit index */
  57.             unsigned char myid ;    /* sender's circuit ID */
  58.             unsigned char window ;    /* sender's proposed window size */
  59.             struct ax25_addr user ;    /* callsign of originating user */
  60.             struct ax25_addr node ;    /* callsign of originating node */
  61.         } conreq ;
  62.  
  63.         struct {                /* connect acknowledge */
  64.             unsigned char yourindex ;/* receipient's circuit index */
  65.             unsigned char yourid ;    /*  receipient's circuit ID */
  66.             unsigned char myindex ;    /* sender's circuit index */
  67.             unsigned char myid ;    /* sender's circuit ID */
  68.             unsigned char window ;     /* accepted window size */
  69.         } conack ;
  70.  
  71.         struct {                /* disconnect request */
  72.             unsigned char yourindex ;/* receipient's circuit index */
  73.             unsigned char yourid ;    /*  receipients's circuit id */
  74.         } discreq ;
  75.  
  76.         struct {                /* disconnect acknowledge */
  77.             unsigned char yourindex ;/* receipient's circuit index */
  78.             unsigned char yourid ;    /*  receipient's circuit id */
  79.         } discack ;
  80.  
  81.         struct {                /* information */
  82.             unsigned char yourindex ;/* receipient's circuit index */
  83.             unsigned char yourid ;    /*  receipient's circuit id */
  84.             unsigned char txseq ;    /* sender's tx sequence number */
  85.             unsigned char rxseq ;    /* sender's rx sequence number */
  86.         } info ;
  87.  
  88.         struct {                /* information acknowledge */
  89.             unsigned char yourindex ;/* receipient's circuit index */
  90.             unsigned char yourid ;    /*  receipient's circuit id */
  91.             unsigned char rxseq ;    /* sender's rx sequence number */
  92.         } ack ;
  93.  
  94.     } u ;    /* End of union */
  95.  
  96. } ;
  97.  
  98. /* The netrom circuit pointer structure */
  99.  
  100. struct nr4circp {
  101.     unsigned char cid ;            /* circuit ID; incremented each time*/
  102.                                 /* this circuit is used */
  103.     struct nr4cb *ccb ;            /* pointer to circuit control block, */
  104.                                 /*  NULLNR4CB if not in use */
  105. } ;
  106.  
  107. /* The circuit table: */
  108.  
  109. extern struct nr4circp nr4circuits[NR4MAXCIRC] ;
  110.  
  111. /* The netrom circuit control block */
  112.  
  113. struct nr4cb {
  114.     unsigned mynum ;            /* my circuit number */
  115.     unsigned myid ;                /* my circuit ID */
  116.     unsigned yournum ;            /* remote circuit number */
  117.     unsigned yourid ;            /* remote circuit ID */
  118.     struct ax25_addr user ;        /* callsign of originating user (if any) */
  119.     struct ax25_addr node ;        /* callsign of remote node */
  120.     unsigned window ;            /* negotiated window size */
  121.     
  122.     struct mbuf *txq ;            /* transmit queue */
  123.     struct mbuf *rxasm ;        /* receive reassembly buffer */
  124.     struct mbuf *rxq ;            /* receive queue */
  125.  
  126.     char choked ;                /* choke received from remote */
  127.  
  128.     unsigned char vs ;            /* send state variable */
  129.     unsigned char vr ;            /* receive state variable */
  130.     unsigned char unack ;        /* number of packets unacked */
  131.  
  132.     int state ;                    /* connection state */
  133. #define NR4STDISC    0            /* disconnected */
  134. #define NR4STCPEND    1            /* connection pending */
  135. #define NR4STCON    2            /* connected */
  136. #define    NR4STDPEND    3            /* disconnect pending */
  137.  
  138.     struct timer tretry ;        /* retry timer */
  139.     struct timer tackdelay ;    /* acknowledgment delay timer */
  140.     struct timer tchoke ;        /* choke timeout */
  141.  
  142.     void (*r_upcall)() ;        /* receive upcall */
  143.     void (*t_upcall)() ;        /* transmit upcall */
  144.     void (*s_upcall)() ;        /* state change upcall */
  145.     char *puser ;                /* user pointer */
  146. } ;
  147.  
  148. /* function definitions */
  149.  
  150. extern int ntohnr4(struct nr4hdr *, struct mbuf **) ;
  151. extern struct mbuf *htonnr4(struct nr4hdr *) ;
  152.  
  153. #endif    /* NR4MAXCIRC */
  154.  
  155.  
  156.